<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>考勤卡库</title>
	<link rel="stylesheet" href="../css/common2.css">
	<style>
		.search_img {
			position: absolute;
			right: 3%;
		}

		.one {
			width: 10%;
		}

		.two {
			width: 16%;
		}

		.three {

			width: 9%;
		}

		.init {
			padding-left: unset;
			width: unset;
		}

		.long-background-img {
			width: 120px;
			height: 35px;
			background: url("image/enter_longer.png") no-repeat center center !important;
		}

		.sort {
			width: 18px;
			height: 18px;
			object-fit: fill;
			transform: translateY(22%);
			cursor: pointer;
		}
	</style>
</head>

<body>
	<div id="vue-root" style="margin-top: 50px;">
		<div>
			<a href="card_item.html" class="add" v-if="able.add">添加卡</a>
			<div class="refresh" onclick="location.reload()">刷新</div>

			<input placeholder="请输入学校名称" class="search" v-model="search.schoolName" @keyup.enter="getData0"
				style="height: 33px; max-width: 120px;right: 240px;">

			<input placeholder="请输入卡号" class="search" v-model="search.cardNo" @keyup.enter="getData0"
				style="height: 33px; max-width: 120px;">
			<img src="../image/search.png" height="35" width="35" class="search_img" @click="getData0">
		</div>
		<form enctype="multipart/form-data" id="form" ref="form" style="display: none;">
			<input type="file" name="file" id="file" @change="importExcel" ref="file"
				accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">
		</form>
		<div class="table" style="margin-left: 2%;">
			<table class="table_top">
				<thead>
					<tr>
						<th class="one">
							<input type="checkbox" class="check-box" v-model="all">
						</th>
						<th>序号</th>
						<th>卡号</th>
						<th>学校</th>
						<th>有效期至</th>
						<th>创建时间 <img @click="sort" class="sort" src="./image/sort.svg" alt="" /> </th>
						<th class="three" v-if="able.edit||able.del">编辑/删除</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(card,index) in list" :key="card.id">
						<td class="one">
							<input type="checkbox" class="check-box" v-model="card.checked">
						</td>
						<td><span v-text="index+1"></span></td>
						<td v-text="card.no"></td>
						<td v-text="card.schoolName"></td>
						<td v-text="format(card.expiryDate)"></td>
						<td v-text="createTime(card)"></td>
						<td class="three" v-if="able.edit||able.del">
							<div class="option">
								<div v-if="able.edit" class="edit-icon option-icon">
									<a :href="'card_item.html?id='+card.id"
										style="position: absolute; left: 20%; top: 30%;">
										<img class="img" src="../image/edit.png" height="20" width="20"
											onmouseover="this.src='image/edit_light.png'"
											onmouseout="this.src='image/edit.png'" />
									</a>
								</div>
								<div v-if="able.del" class="delete-icon option-icon" @click="del([card.id])"
									style="right: 20%; top:30%;position: absolute;">
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='image/delete_light.png'"
										onmouseout="this.src='image/delete.png'" />
								</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<div class="delete" @click="batchDelete" v-if="able.del||total>1">批量删除</div>
		<div class="delete long-background-img" v-if="able.add">
			<a href="/excel/card.xls" style="color: white;">下载导入模板</a>
		</div>
		<div class="delete long-background-img" v-if="able.add">
			<label for="file">批量导入</label>
		</div>
		<div class="delete long-background-img" v-if="able.add" @click="force">
			强制导入
		</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
			<li><a v-text="pages"></a></li>
		</ul>
		<div style="float: right;margin-bottom: 20px;">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>


	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>

		var app = new Vue(merge({
			data: {
				urls: {
					del: '/pc/card/del',
					imports: '/pc/card/import',
					list: '/pc/card/list'
				}

			},
			created: function () {
				if (/agent/.test(top.location.href))
					this.search.agentId = top_params().id;

				this.getData();
				abled('card', this);
			},
			methods: {
				format: function (time) {
					if (!time) return null;
					return dayjs(time).format('YYYY-MM-DD');
				},
				createTime: function (item) {
					return dayjs(item.id / 4096 + 1.56E12).format('YYYY-MM-DD HH:mm:ss');
				},
				force: function () {
					this.urls.imports = "/pc/card/import0";
					this.$refs.file.click();
				},
				sort() {
					this.search.asc = !this.search.asc;
					this.getData0()
				}
			}
		}));
	</script>

</body>

</html>